﻿namespace Leetcode.N0003;
/// <summary>
/// 暴力算法
/// </summary>
public class Solution
{
    public int LengthOfLongestSubstring(string s)
    {
        var maxLength = 0;
        for (int i = 0; i < s.Length; i++)
        {
            var flag = new bool[256];
            var length = 0;
            for (int j = i; j < s.Length; j++)
            {
                var pos = (int)s[j];

                if (flag[pos])
                {
                    break;
                }
                flag[pos] = true;
                length++;
            }
            if (length >= maxLength)
            {
                maxLength = length;
            }
        }
        return maxLength;

    }
}
